#include <string>
#include <algorithm>
#include <iostream>
#include <vector>
using namespace std;

class LeftOrRight
{
public:
	int maxDistance(string program)
	{
		// 0 L, 1 R
		int md[2][60] = {0};
		if(program[0] == 'L')
		{
			md[0][0] = 1;
			md[1][0] = -1;
		}
		else if(program[0] == 'R')
		{
			md[0][0] = -1;
			md[1][0] = 1;
		}
		else
		{
			md[0][0] = 1;
			md[1][0] = 1;
		}

		for(int i = 1; i < program.length(); ++i)
		{
			if(program[i] == 'L')
			{
				md[0][i] = md[0][i-1] + 1;
				md[1][i] = md[1][i-1] - 1;
			}
			else if(program[i] == 'R')
			{
				md[0][i] = md[0][i-1] - 1;
				md[1][i] = md[1][i-1] + 1;
			}
			else
			{
				md[0][i] = md[0][i-1] + 1;
				md[1][i] = md[1][i-1] + 1;
			}
		}

		int* maxL = max_element(&md[0][0], &md[0][0]+program.length());
		int* maxR = max_element(&md[1][0], &md[1][0]+program.length());
		
		return max(*maxL, *maxR);
	}
};

class EvenRoute
{
public:
	string isItPossible(vector <int> x, vector <int> y, int wantedParity)
	{
		vector<int> v1;
		vector<int> v2;
		for(int i = 0; i < x.size(); ++i)
		{
			if(!v1.empty())
			{
				for(int j = 0; j < v1.size(); ++j)
				{
					int tmp = abs(x[i]-x[v1[j]]) + abs(y[i]-y[v1[j]]);
					if(tmp%2 == 0)
						v1.push_back(i);
					else
						v2.push_back(i);
					break;
				}
			}
			else
				v1.push_back(i);
		}

		if(wantedParity == 0)
		{
			if(v1.empty() && !v2.empty()
				|| !v1.empty() && v2.empty())
			{
				for(int i = 0; i < x.size(); ++i)
				{
					int tmp = abs(x[i]) + abs(y[i]);
					if(tmp%2 == 0)
					{
						return "CAN";
					}
				}
				return "CANNOT";
			}
			else
			{
				for(int i = 0; i < x.size(); ++i)
				{
					int tmp = abs(x[i]) + abs(y[i]);
					if(tmp%2 == 1)
					{
						return "CAN";
					}
				}
				return "CANNOT";
			}
		}
		else
		{
			if(v1.empty() && !v2.empty()
				|| !v1.empty() && v2.empty())
			{
				for(int i = 0; i < x.size(); ++i)
				{
					int tmp = abs(x[i]) + abs(y[i]);
					if(tmp%2 == 1)
					{
						return "CAN";
					}
				}
				return "CANNOT";
			}
			else
			{
				for(int i = 0; i < x.size(); ++i)
				{
					int tmp = abs(x[i]) + abs(y[i]);
					if(tmp%2 == 0)
					{
						return "CAN";
					}
				}
				return "CANNOT";
			}
		}
	}
};

int main()
{
	LeftOrRight lor;
	cout<<lor.maxDistance("LL???RRRRRRR???")<<endl;

	return 0;
}